<template>
  <page-header-wrapper :title="false">
    <a-card title="帖子待审核列表">
      <s-table
        bordered
        ref="table"
        :row-key="(record) => record.id"
        :columns="questionColumns"
        :data="questionData"
      >
        <template slot="action" slot-scope="text,record">
          <a-button size="small" type="primary" @click="checkQuestion(record.id)">审核</a-button>
        </template>
      </s-table>
    </a-card>
  </page-header-wrapper>
</template>

<script>
import { STable } from '@/components'
import col from '@/columns/bbs'
import { checkQuestion, getQuestionCheck } from '@/api/bbs'
const questionColumns = col.check
export default {
  components: {
    STable
  },
  name: 'BBSList',
  data () {
    return {
      questionColumns,
      questionData: parameters => {
        return getQuestionCheck(Object.assign(parameters, this.queryParam)).then(res => {
          return res.result
        })
      },
      queryParam: {}
    }
  },
  methods: {
    checkQuestion (id) {
      this.$confirm({
        title: '确定审核这篇帖子',
        onOk: () => {
          checkQuestion(id, '1').then(res => {
            if (res.status === 0) {
              this.$refs.table.refresh(true)
            }
          })
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
